<!--# layout("/common/layout.html",{"jsBase":"/js/evaluation/cpTaskSetup/"}){ -->

<form class="layui-form layui-form-pane" id="addForm" enctype="multipart/form-data"  lay-filter="editform">

    <br/>

    <input type="hidden" name="taskId" id="taskId">
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">任务名称</label>
				<div class="layui-input-inline">
                        <input type="text" name="taskName" id="taskName" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required">
				</div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">测评模型</label>
                <div class="layui-input-inline">
                    <layui:simpleDataSelect name="tplId" value="" data="${tempList}" attrId="tplId" attrName="tplName" layFilter="Filter" id="tplId" laySearch="true" layVerify="required"/>
                </div>
            </div>

        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="beginTime"  id="beginTime" autocomplete="off"  maxlength="50" class="layui-input"   placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="endTime"  id="endTime" autocomplete="off"  maxlength="50" class="layui-input"   placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
            </div>

        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">总参与人数</label>
                <div class="layui-input-inline">
                    <input type="text" name="totalNum" id="totalNum" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required|number">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">测评人数</label>
                <div class="layui-input-inline">
                    <input type="text" name="assessNum" id="assessNum" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required|number">
                </div>
            </div>
        </div>
    </div>


    <div class="layui-row">
        <div class="layui-form-item">

            <div class="layui-inline">
                <label class="layui-form-label">被测评人数</label>
                <div class="layui-input-inline">
                    <input type="text" name="beassessNum" id="beassessNum" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required|number">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">测评分组</label>
                <div class="layui-input-inline">
                    <select class="select" name="taskGroup" id="taskGroup"  promtion="请选择"  lay-filter="code" lay-verify="required">
                        <option value="" >请选择</option>
                        <option value="财务部" >财务部</option>
                        <option value="行政部" >行政部</option>
                    </select>
                </div>
            </div>

        </div>
    </div>


    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">任务状态</label>
				<div class="layui-input-inline">
                    <select class="select" name="taskStatus" id="taskStatus"  promtion="请选择"  lay-filter="code" lay-verify="required">
                        <option value="1" >待审核</option>
                        <option value="2" >已审核</option>
                        <option value="3" >已发布</option>
                        <option value="4" >取消发布</option>
                    </select>
				</div>
            </div>

        </div>
    </div>

    <div>
         <layui:singleFile id="assessFile" tagName="测评数据文件" tips="只支持.xls或者.xlsx文件"/>
    </div>

    </br>
    <button class="layui-btn layui-btn-danger" type="button" id="addButton" lay-submit="" lay-filter="form">数据校验</button>
    <button class="layui-btn" type="button" id="addButton-cancel">下一步</button>

</form>


<!--#} -->
<script>

function callback(){
    parent.window.dataReload();
    Lib.closeFrame();
}
layui.extend({
    loading: '../../../plugins/layui_extends/loading/loading',
}).define([ 'form', 'laydate', 'table','loading','cpTaskSetupApi'], function(exports) {
    var form = layui.form;
    var cpTaskSetupApi = layui.cpTaskSetupApi;
    var index = layui.index;
    var isNew = true;

    var laydate = layui.laydate;

    //常规用法
    laydate.render({
        elem: '#beginTime',
        type: 'datetime',
        format: 'yyyy-MM-dd HH:mm:ss'
    });

    //常规用法
    laydate.render({
        elem: '#endTime',
        type: 'datetime',
        format: 'yyyy-MM-dd HH:mm:ss'
    });

    <!--# if(!(isEmpty(cpTaskSetupJson))){  -->
    isNew = false;
    <!--# } -->
    // $("#addButton-cancel").hide();
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                $("#addButton-cancel").show();
                //$("#addButton").hide();
                // $("#addButton-loading").show();
                // $("#addButton").hide();
                // $("#addButton-loading").loading();
                form.on('submit(form)', function(){
                    cpTaskSetupApi.saveForm(isNew,$('#addForm'),function(data){
                        // parent.window.dataReload();
                        Common.info("数据校验成功，请进行下一步操作！");
                        // Lib.closeFrame();

                        $('#addButton').attr("disabled",true);
                        //$("#addButton").disable();
                        $("#taskId").val(data)
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                if($("#taskId").val()==""){
                    Common.info("请校验数据");
                    return;
                }
                var url = Common.ctxPath+"/evaluation/cpTaskSetup/ruleindex.do?taskId="+$("#taskId").val();
                var rule = layui.layer.open({
                    title: "",
                    type: 2,
                    content:url,//弹出层页面
                    // area: ['850px', '700px'],
                    area: ['100%', '100%'],
                        success:function () {
                    }
                });
                layer.full(rule);
            });
        }

    }

    view.init();
    <!--# if(!(isEmpty(cpTaskSetupJson))){  -->
    var formJson = ${cpTaskSetupJson};
    form.val("editform",formJson);
    /*$(".file_link").each(function() {
        var a=document.createElement('a');
        var aJq = $(a);
        aJq.html("下载文件");
        aJq.attr("href",formJson[$(this).attr("id")]);
        aJq.attr("target","_blank");
        $(this).append(aJq);
    });*/
    <!--# } -->
});
</script>
